package cn.net.cfss.fgbp.provider.manage.biz;

import cn.net.cfss.fgbp.base.common.biz.BaseBiz;
import cn.net.cfss.fgbp.provider.manage.dao.FscTenantDtoMapper;
import cn.net.cfss.fgbp.provider.manage.service.CacheService;
import cn.net.cfss.fgbp.spi.manage.dto.FscTenantDto;
import cn.net.cfss.fgbp.spi.manage.vo.FscTenantVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.*;

/**
 * @author wutao
 * @version 1.0
 * @date 2020/9/4 11:37
 */
@Slf4j
@Service
public class FscTenantBiz extends BaseBiz<FscTenantDtoMapper, FscTenantDto> {

    @Autowired
    private CacheService cacheService;

    public List<FscTenantVo> queryPage(FscTenantVo search) {
        return mapper.queryPage(search);
    }

    public String queryNewestCode() {
        //获取最新编号
        return mapper.queryNewestCode();

    }



    public List<FscTenantDto> queryByIds(List<Long> ids) {
        if (ids == null || ids.isEmpty()) {
            return new ArrayList<>();
        }
        return mapper.queryByIds(ids);
    }

    public List<FscTenantVo> list(FscTenantVo fscTenantVo) {
        return mapper.list(fscTenantVo);
    }

    public Map<Long, FscTenantDto> queryMapByIds(List<Long> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return new HashMap<>();
        }
        List<FscTenantDto> list = mapper.queryByIds(ids);
        Map<Long, FscTenantDto> result = new HashMap<>();
        for (FscTenantDto fscTenantDto : list) {
            result.put(fscTenantDto.getId(), fscTenantDto);
        }
        return result;
    }
}
